package com.sky.config;

import com.sky.properties.HaiweiOBSProperties;
import com.sky.utils.HaiweiOBSUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class OBSConfiguration {

    @Bean
    @ConditionalOnMissingBean // 表示只创建一个类
    public HaiweiOBSUtil haiweiOBSUtil(HaiweiOBSProperties haiweiOBSProperties) {
        log.info("开始上传华为云工具类对象：{}",haiweiOBSProperties);
        return new HaiweiOBSUtil(haiweiOBSProperties.getEndpoint(),haiweiOBSProperties.getAccessKeyId(),
                haiweiOBSProperties.getAccessKeySecret(),haiweiOBSProperties.getBucketName());
    }
}
